<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav main-header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            分层审核任务单列表
        </div>
    </header>
    <script id="chkBillTemp" type="text/x-dot-template">

        {{~ it:value:index}}
        <li class="aui-list-item" onclick="setTask('{{= it[index].taskId }}','{{= it[index].taskCode }}','{{= it[index].planCode }}','{{= it[index].chkGid }}','{{= it[index].beginDate }}','{{= it[index].taskState }}','{{= it[index].taskResult }}','{{= it[index].endDate }}','{{= it[index].areaId }}','{{= it[index].areaIdOne }}');">
            <div class="aui-media-list-item-inner">
                <div class="aui-list-item-inner ">
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title aui-font-size-14">
                            任务编码：{{= it[index].taskCode }}
                        </div>
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        维护计划编码：{{= it[index].planCode }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        维护模板名称：{{= it[index].chkName }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        计划开始时间：{{= it[index].beginDate }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        计划结束时间：{{= it[index].endDate }}
                    </div>
                    <div class="aui-font-size-12" style=" word-wrap: break-word;overflow-wrap: break-word;white-space: normal;">
                        审核区域：<span id="areaReds" style="color: red;">{{= it[index].areaReds }}</span>
                                  <span id="areaGreens" style="color: green; ">{{= it[index].areaGreens }}</span>
                    </div>                                      
                </div>
            </div>
        </li>
        {{~}}

    </script>
    <div class="aui-bar aui-bar-nav sub-header"></div>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="white_background">
            <div class="aui-form" style="margin-top:15px;">
                <div class="aui-content aui-margin-b-15">
                    <ul class="aui-list aui-form-list">
                        <li class="aui-list-item">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-label" style="width:150px">起始日期</div>
                                <div class="aui-list-item-input" onclick="timePicker();">
                                    <input type="text" placeholder="选择日期" style="padding-left: 20px;" class="aui-input"
                                        id="startTime">
                                </div>
                            </div>
                        </li>
                        <li class="aui-list-item">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-label" style="width:150px">结束日期</div>
                                <div class="aui-list-item-input" onclick="timePickerEnd();">
                                    <input type="text" placeholder="选择日期" style="padding-left: 20px;" class="aui-input"
                                        id="endTime">
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div style="width:100%;margin-top:2%;"></div>
    <div class="aui-btn aui-btn-info aui-btn-block" style="margin:0 5%;width: 90%;" onclick="doSearch()">查询</div>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list" id="taskList">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var boxnum = "";
    apiready = function () {
        doSearch()
    };

    //时间选择器
    function timePicker() {
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function (ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#startTime").val(date);
                doSearch();
            }
        });
    }
    //时间选择器
    function timePickerEnd() {
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function (ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#endTime").val(date);
                doSearch();
            }
        });
    }
    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }


    //箱号监听回车事件
    $("#rsCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            if (tm != null && tm != "" && tm != undefined) {
                doSearch();
            }
        }
    });


    //查询资源维护任务
    function doSearch() {

        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/geChkTaskLpa";
        var data = {
            values: {
                endTime: endTime,
                un: un,
                starTime: startTime
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);

                    var evaluation = doT.template($api.dom('#chkBillTemp').innerHTML);
                    $api.dom('#taskList').innerHTML = evaluation(list);

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //选则返回函数
    function setTask(taskId, taskCode, planCode, chkGid, beginDate, taskState, taskResult, endDate, areaId, areaIdOne) {
        api.closeWin();
        var name = api.pageParam.name;
        api.execScript({
            name: 'lpaMntTask',
            script: 'setTask("' + taskId + '","' + taskCode + '","' + planCode + '","' + chkGid + '","' + beginDate + '","' + beginDate + '","' + taskResult + '","' + endDate + '","' + areaId + '","' + areaIdOne + '")'
        });
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>